import java.io.BufferedReader;
import java.io.IOException;

public class PrintMessage {
    private League league;
    private BufferedReader reader;

    public PrintMessage (League league, BufferedReader reader){
        this.league = league;
        this.reader = reader;
    }

    public void printList() {
        league.listPlayerInfos();
    }

    public void printInvalidSelectionMessage() {
        System.out.println("Please pick a valid option.");
    }

    public void printPlayerSelectionMessage() {
        System.out.println("Please enter the name of player you'd like to find");
    }

    private void printTeamSelectionMessage() {
        System.out.println("Please enter the name of the team you'd like to view");
    }

    public void respondToInput(String input) throws IOException {
        if (input.equals("View All Players")){
            printList();
        }
        else if(input.equals("Find Player")){
            printPlayerSelectionMessage();
            String name = reader.readLine();
            league.findPlayer(name);
        }
        else if(input.equals("View Team")){
            printTeamSelectionMessage();
            String name = reader.readLine();
            league.listTeam(name);

        }
        else if(input.equals("Trade Player")){
            System.out.println("Enter the name of the player you'd like to trade");
            String name = reader.readLine();
            System.out.println("Enter the name of the team to trade the player to");
            String toTeam = reader.readLine();
            league.tradePlayer(name, toTeam);
        }
        else {
            printInvalidSelectionMessage();
        }

    }


}
